<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改设备管理')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-bras-edit" th:object="${bras}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">标识：</label>
                <div class="col-sm-8">
                    <input name="identifier" th:field="*{identifier}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">IP地址：</label>
                <div class="col-sm-8">
                    <input name="ipaddr" th:field="*{ipaddr}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">设备厂商：</label>
                <div class="col-sm-8">
                    <select name="vendorId" class="form-control m-b" th:with="type=${@dict.getType('radius_vendor_list')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{vendorId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">portal协议：</label>
                <div class="col-sm-8">
                    <select name="portalVendor" class="form-control m-b" th:with="type=${@dict.getType('radius_portal_list')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{portalVendor}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">共享密钥：</label>
                <div class="col-sm-8">
                    <input name="secret" th:field="*{secret}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">COA端口：</label>
                <div class="col-sm-8">
                    <input name="coaPort" th:field="*{coaPort}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">AC端口：</label>
                <div class="col-sm-8">
                    <input name="acPort" th:field="*{acPort}" class="form-control" type="number" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">认证并发：</label>
                <div class="col-sm-8">
                    <input name="authLimit" th:field="*{authLimit}" class="form-control" type="number" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">记账并发：</label>
                <div class="col-sm-8">
                    <input name="acctLimit" th:field="*{acctLimit}" class="form-control" type="number" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('radius_bras_status')}">
                        <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "radius/bras";
        $("#form-bras-edit").validate({
            onkeyup: false,
            rules:{
                identifier:{
                    minlength: 1,
                    maxlength: 20,
                    remote: {
                        url: prefix + "/checkIdentifierUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "identifier": function() {
                                return $.common.trim($("input[name='identifier']").val());
                            },
                            "id": function() {
                                return $("#id").val();
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
                ipaddr:{
                    isIp:true
                }
            },
            messages: {
                "identifier": {
                    remote: "唯一标识已经存在"
                },
                "ipaddr":{
                    isIp:"IP地址不正确"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-bras-edit').serialize());
            }
        }
    </script>
</body>
</html>